package com.realtyManage.springboot.Service.impl;

import com.realtyManage.springboot.Dao.FavouriteRepository;
import com.realtyManage.springboot.Model.Do.Favourite;
import com.realtyManage.springboot.Service.IFavouriteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

/**
 * FavouriteServiceImpl
 *
 * @Author 杭州素色网络科技有限公司
 * @Date 2019/5/4
 **/
@Service
@Transactional
public class FavouriteServiceImpl implements IFavouriteService{
    @Autowired
    private FavouriteRepository favouriteRepository;

    @Override
    public Favourite findByConnUserIdAndConnHouseIdAndState(int uid, int connHouseId, int state) {
        return favouriteRepository.findByConnUserIdAndConnHouseIdAndState(uid,connHouseId,state);
    }

    @Override
    public Favourite save(Favourite favourite) {
        return favouriteRepository.save(favourite);
    }

    @Override
    public Favourite getOne(int favId) {
        return favouriteRepository.getOne(favId);
    }

    @Override
    public List<Favourite> getMyFavouriteList(int uid) {
        return favouriteRepository.findByConnUserIdAndStateOrderByInsertDateDesc(uid,1);
    }
}
